﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNet.Random.Email
{
    /// <summary>
    /// email随机类，实现了IStringRandService
    /// </summary>
    public class EmailRandService : DotNet.Random.Interface.IStringRandService
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="EmailRandService" /> class.
        /// </summary>
        /// <param name="count">The count.</param>
        public EmailRandService(int count)
        {
            if (count <= 0)
            {
                count = 4;
            }
            this.Count = count;
        }

        /// <summary>
        /// Gets or sets the count.
        /// email前缀长度
        /// </summary>
        /// <value>
        /// The count.
        /// </value>
        public int Count { get; set; }

        /// <summary>
        /// Rands this instance.
        /// 随机生成字符串方法
        /// 映射到虚方法中，扩展时，可重写
        /// </summary>
        /// <returns>
        /// 返回字符串类型
        /// </returns>
        public virtual string Rand()
        {
            var preffixRand = new DotNet.Random.String
                .EngishLetterRandService(this.Count, "");
            var res = preffixRand.Rand();

            var suffixRand = new DotNet.Random.Email.EmailSuffixRandService();
            res += suffixRand.Rand();

            System.Threading.Thread.Sleep(200);
            return res;
        }
    }
}
